<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/20
 * Time: 21:34
 */

class LyOrder_model extends CI_Model
{

    public function order_list($offset = 0, $limit_rows = 15)
    {
        $this->db->select('*');
        $this->db->from('ly_order_info');
        $this->db->limit($limit_rows,$offset);
        $this->db->order_by('order_id DESC');
        $query = $this->db->get();

        return $query->result_array();
    }

    public function order_num()
    {
        return $this->db->count_all('ly_order_info');
    }

    public function order_goods_num($goods_id)
    {
        $this->db->select('SUM(og.goods_number) AS goods_number, pc.web_name');
        $this->db->from('ly_order_goods AS og');
        $this->db->join('ly_order_info AS oi', 'og.order_id = oi.order_id', 'left');
        $this->db->join('pco_site AS pc', 'oi.web_id = pc.web_id', 'left');
        $this->db->group_by('oi.web_id');
        $this->db->where('og.goods_id', $goods_id);

        $query = $this->db->get();
        return $query->result_array();
    }
}